/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2017_11_01			*/
/*	File:		CmProto.h			*/
/********************************************************/

#ifndef	_CMPROTO_H
#define	_CMPROTO_H

#include "CmAdxDef.h"

class CCmProto
{
public:
	CCmProto() {}
	virtual ~CCmProto() {}

	virtual int CmProtoSerialize(CMADXPARA_S*) = 0;
	virtual int CmProtoDeserialize(CMADXPARA_S*) = 0;

	virtual CMADXINFO_S* CmProtoValidity(char*) = 0;

	virtual CMSTR_C CmProtoSerialize(CMADXINFO_S*) = 0;
	virtual CMADXINFO_S* CmProtoDeserialize(char*) = 0;

	CMADXINFO_S& CmProtoInfo() {return m_stInfo;}
	void CmProtoAdxInfoPrint() {
		const char* pszReq[] = CM_ADF_TREQ;
		const char** ppszReq = &pszReq[0];
		CM_PRINT("CmProtoDeserialize:\n{\n");
		CM_PRINT("\t\"%s\": %d,\n", *ppszReq ++, m_stInfo.m_uiVer);
		CM_PRINT("\t\"%s\": %d,\n", *ppszReq ++, m_stInfo.m_uiDsp);
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CCtxtid.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CIP.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CUid.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CMac.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CGps.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CImei.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CUa.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CDid.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CAid.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CEid.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CCid.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CCats.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CType.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CWidth.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CHeight.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszReq ++, m_stInfo.m_CScaling.c_str());
		CM_PRINT("\t\"%s\": %d,\n", *ppszReq ++, m_stInfo.m_uiCrtView);
		CM_PRINT("\t\"%s\": %d,\n", *ppszReq ++, m_stInfo.m_uiMinPrice);
		const char* pszRes[] = CM_ADF_TRES;
		const char** ppszRes = &pszRes[0];
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CAdvId.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CDesUrl.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CClkUrl.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CSupUrl.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CExtend.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CCategory.c_str());
		CM_PRINT("\t\"%s\": %d,\n", *ppszRes ++, m_stInfo.m_uiCode);
		CM_PRINT("\t\"%s\": %d,\n", *ppszRes ++, m_stInfo.m_uiMethod);
		CM_PRINT("\t\"%s\": %d,\n", *ppszRes ++, m_stInfo.m_uiMaxPrice);
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CCrtId.c_str());
		CM_PRINT("\t\"%s\": \"%s\",\n", *ppszRes ++, m_stInfo.m_CCrtTitle.c_str());
		CM_PRINT("\t\"%s\": %d,\n}\n", *ppszRes ++, m_stInfo.m_uiCrtType);

		return;
	}

protected:
	CMADXINFO_S	m_stInfo;

private:

};

#endif /* _CMPROTO_H */
